﻿@model DLMemberPointMS.Entity.POCOModel.MemCards
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link rel="stylesheet" type="text/css" href="~/layui/css/layui.css" />
    <script src="~/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <script src="~/layui/jquery-3.4.1.js" type="text/javascript" charset="utf-8"></script>

    <title>EditMember</title>
    <style type="text/css">
        .layui-input {
            height: 30px;
        }
        #check1 div span {
            font-size: 5px
        }
    </style>
</head>
<body>
    <fieldset class="layui-elem-field layui-field-title">
        <legend>新增会员</legend>
    </fieldset>
    @using (Html.BeginForm("123", "123", FormMethod.Post, new { @class = "layui-form" }))
    {
        <div class="layui-input-inline">
            <label class="layui-form-label">会员卡号</label>
            <div class="layui-input-block">
                @*<input type="text" name="vip_ID" class="layui-input" />*@
                @Html.EditorFor(model => model.MC_CardID, new { htmlAttributes = new { @class = "layui-input", lay_verify = "required" } })
            </div>
        </div><br>
        <div class="layui-input-inline">
            <label class="layui-form-label">会员姓名</label>
            <div class="layui-input-block">
                @Html.EditorFor(model => model.MC_Name, new { htmlAttributes = new { @class = "layui-input", lay_verify = "required" } })
                @*<input type="text" name="name" class="layui-input" />*@
            </div>
        </div>
        <div class="layui-input-inline">
            <label class="layui-form-label">手机号码</label>
            <div class="layui-input-block">
                @Html.EditorFor(model => model.MC_Mobile, new { htmlAttributes = new { @class = "layui-input", lay_verify = "required" } })
                @*<input type="text" name="tel" class="layui-input" />*@
            </div>
        </div><br>
        <div class="layui-input-inline">
            <label class="layui-form-label">卡片密码</label>
            <div class="layui-input-block">
                @Html.EditorFor(model => model.MC_Password, new { htmlAttributes = new { @class = "layui-input", id = "pwd1", lay_verify = "required", type = "text" } })
                @*<input type="text" name="pwd" class="layui-input" />*@
            </div>
        </div>
        <div class="layui-input-inline">
            <label class="layui-form-label">确认密码</label>
            <div class="layui-input-block">
                <input type="text" name="" lay-verify="MC_Password_confirm|required" class="layui-input" />
            </div>
        </div>
        <br>
        <div class="layui-input-inline">
            <label class="layui-form-label"> 会员性别</label>
            <div class="layui-input-inline" style="width: 180px;">
                @*<select name="sex">
                        <option value="2">未知</option>
                        <option value="1">男</option>
                        <option value="0">女</option>
                    </select>*@
                @Html.DropDownList("MC_Sex", (ViewData["sex"]) as IEnumerable<SelectListItem>, new { id = "MC_Sex", lay_verify = "required" })
            </div>
        </div>
        <div class="layui-input-inline">
            <label class="layui-form-label"> 会员等级</label>
            <div class="layui-input-inline" style="width: 180px; ">

                @Html.DropDownList("CL_ID", (ViewData["levels"]) as IEnumerable<SelectListItem>, new { id = "CL_ID", lay_verify = "required" })
            </div>
        </div>
        <br />
        <div class="layui-input-inline">
            <label class="layui-form-label">会员生日</label>
            <div class="layui-input-block">
                @Html.RadioButtonFor(r => r.MC_BirthdayType, 0, new { title = "农历" })
                @Html.RadioButtonFor(r => r.MC_BirthdayType, 1, new { title = "公历" })
            </div>

        </div>
        <div class="layui-input-inline" style="padding-left: 60px;">
            <div class="layui-input-inline">
                @Html.EditorFor(model => model.MC_Birthday_Month, new { htmlAttributes = new { @class = "layui-input", style = "width: 80px;", lay_verify = "required" } })
                @*<input type="text" name="mon" class="layui-input" style="width: 80px;" />*@
            </div>月
            <div class="layui-input-inline">
                @Html.EditorFor(model => model.MC_Birthday_Day, new { htmlAttributes = new { @class = "layui-input", style = "width: 80px;", lay_verify = "required" } })
                @*<input type="text" name="day" class="layui-input" style="width: 80px;" />*@
            </div>日
        </div><br>
        <div class="layui-input-inline">
            <div class="layui-form-item" pane="">
                <div class="layui-input-block" id="check1">
                    @*<input type="checkbox" name="shixoao" lay-skin="primary" title="设置卡片失效时间">*@
                    @Html.CheckBoxFor(c => c.MC_IsPast, new { lay_skin = "primary", style = "font-size:5px", title = "设置卡片失效时间,到期后卡片失效", lay_filter = "IsPast" })
                </div>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">失效日期</label>
            <div class="layui-input-inline">
                <div class="layui-form-item">
                    @Html.EditorFor(model => model.MC_PastTime, new { htmlAttributes = new { id = "PastTime", @class = "layui-input", lay_verify = "date", autocomplete = "off", lay_filter = "PastTime" } })
                    @*Value = Model.MC_PastTime.ToString("yyyy-MM-dd"),*@
                </div>
            </div>
        </div>
        <br />
        <div class="layui-input-inline">
            <label class="layui-form-label">卡片状态</label>
            <div class="layui-input-inline" style="width: 180px;">
                @*<select name="state">
                        <option value="1">正常</option>
                        <option value="-1">异常</option>
                    </select>*@

                @Html.DropDownList("MC_State", (ViewData["state"]) as IEnumerable<SelectListItem>, new { id = "MC_State", lay_verify = "required" })
            </div>
        </div>
        <div class="layui-input-inline">
            <label class="layui-form-label">卡片付费</label>
            <div class="layui-input-block">
                @Html.EditorFor(model => model.MC_Money, new { htmlAttributes = new { @class = "layui-input", lay_verify = "required" } })
                @*<input type="text" name="card_money" class="layui-input" />*@
            </div>
        </div>
        <hr>
        <div class="layui-input-inline">
            <label class="layui-form-label">积分数量</label>
            <div class="layui-input-block">
                @Html.EditorFor(model => model.MC_Point, new { htmlAttributes = new { @class = "layui-input", lay_verify = "required" } })
                @*<input type="text" name="card_integral" class="layui-input" />*@
            </div>
        </div>
        <div class="layui-input-inline">
            <div class="layui-form-item" pane="">
                <div class="layui-input-block">
                    @*@Html.EditorFor(model => model.MC_IsPointAuto, new { htmlAttributes = new { @class = "layui-input" } })*@
                    @*<input type="checkbox" name="zhuanhuan" lay-skin="primary" title="积分是否可转换成等级">*@
                    @*<input type="checkbox" id="chkPoint" name="Point" lay-skin="primary" title="积分是否可转换成等级">*@
                    @Html.CheckBoxFor(c => c.MC_IsPointAuto, new { lay_skin = "primary", title = "积分是否可转换成等级" })
                </div>
            </div>
        </div>
        <br />
        <div class="layui-input-inline">
            <label class="layui-form-label">推荐人</label>
            <div class="layui-input-block">
                @Html.EditorFor(model => model.MC_RefererName, new { htmlAttributes = new { @class = "layui-input" } })
                @*<input type="text" name="tuijianren" class="layui-input" />*@
            </div>
        </div>
        <div class="layui-input-inline">
            <button type="button" class="layui-btn layui-btn-xs layui-btn-warm" id="new"><i class="layui-icon">&#xe615;查找</i></button>
        </div>
        <div class="layui-input-inline">
            <label class="layui-form-label">新增推荐人</label>
            <div class="layui-input-block">
                @Html.EditorFor(model => model.MC_RefererName, new { htmlAttributes = new { @class = "layui-input" } })
                @*<input type="text" name="new_tuijianren" class="layui-input" />*@
            </div>
        </div>
        <br>
        <div class="layui-input-inline">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <button type="button" class="layui-btn layui-btn-sm" lay-submit lay-filter="submitform"><i class="layui-icon">&#xe654;确定</i></button>
            </div>
        </div>
        <div class="layui-input-inline">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <button type="button" class="layui-btn layui-btn-sm" id="close"><i class="layui-icon">关闭</i></button>
            </div>
        </div>
        @Html.HiddenFor(model => model.MC_ID)
    }



    <script>
        layui.use(['layer', 'form', 'laydate'], function () {
            var layer = layui.layer,
                form = layui.form,
                laydate = layui.laydate;
            laydate.render({
                elem: '#PastTime', //指定元素
                trigger: 'click'

            });

            if ($('.MC_IsPast').checked) {
                layer.mag('ok')


            }

            //当选中卡片失效时间时，禁用时间选择框

            form.on('checkbox(IsPast)', function (data) {
                if (!data.elem.checked) {
                    $('#PastTime').addClass("layui-disabled").attr("disabled", "")
                }
                if (data.elem.checked) {
                    $('#PastTime').removeClass("layui-disabled").removeAttr("disabled", "")
                }
            })




            //自定义表单验证
            form.verify({
                MC_Password_confirm: function (value, item) {
                    //value：表单的值、item：表单的DOM对象
                    if ($('#pwd1').val() != value) {
                        return '两次密码不一致';
                    }

                }
            });


            form.on('submit(submitform)', function (data) {
                var MC_ID = $('#MC_ID').val();
                var index = parent.layer.getFrameIndex(window.name); //得到当前iframe层的索引
                //var strdatas = JSON.stringify(data.field);
                var formdata = $('.layui-form').serializeArray();
                var url = '/Member/AddMemberResult';
                if (parseInt(MC_ID) > 0) {
                    var url = '/Member/EditMemberResult'
                }
                $.ajax({
                    type: "post",
                    url: url,
                    data: formdata,
                    success: function (res) {
                        if (res.code == 0) {
                            parent.layer.msg(res.msg, { icon: 1 });
                            parent.layer.close(index); //再执行关闭

                        } else {
                            parent.layer.msg(res.msg, { icon: 5 });
                        }
                    },
                    error: function (res) {
                        parent.layer.msg(res.msg, { icon: 2 });
                    }
                })
                return false;
            })
            $('#close').click(function () {
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            })

        });

    </script>
</body>
</html>
